package cn.com.spic.demo.impl;

import cn.com.spic.demo.api.BenchMarService;
import cn.com.spic.demo.dao.BenchMarkDAO;
import cn.com.spic.demo.dto.BenchMarkDTO;
import cn.com.spic.demo.po.BenchMarkPO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @ProjectName: demo-contract-provider
 * @Package: cn.com.spic.demo.impl
 * @ClassName: BenchMarkServiceImpl
 * @Date: 2021/1/29 11:54
 * @Author: 铁板烤翅
 */

@RequiredArgsConstructor
@Service
public class BenchMarkServiceImpl implements BenchMarService {

//    private final BenchMarObjService benchMarObjService;

    @Autowired
    BenchMarkDAO benchMarkDAO;

    @Override
    public List<BenchMarkDTO> getBenchMark(Map<String, Integer> map) {
        List<BenchMarkDTO> benchMarkDTOS = new ArrayList<>();
        List<BenchMarkPO> benchMarkPOS = benchMarkDAO.getBenchMark(map);
        if (benchMarkPOS != null && benchMarkPOS.size() > 0) {
            for (BenchMarkPO po : benchMarkPOS) {
                BenchMarkDTO dto = new BenchMarkDTO();
                BeanUtils.copyProperties(po, dto);
                benchMarkDTOS.add(dto);
            }
        }
        return benchMarkDTOS;
    }


    @Override
    public List<BenchMarkDTO> getBenchMarkById(String[] ids) {
        List<BenchMarkDTO> benchMarkDTOS = new ArrayList<>();
        List<BenchMarkPO> benchMarkPOS = benchMarkDAO.getBenchMarkById(ids);
        if (benchMarkPOS != null && benchMarkPOS.size() > 0) {
            for (BenchMarkPO po : benchMarkPOS) {
                BenchMarkDTO dto = new BenchMarkDTO();
                BeanUtils.copyProperties(po, dto);
                benchMarkDTOS.add(dto);
            }
        }
        return benchMarkDTOS;
    }
}
